<?php   // $Id: client_lister.php 275 2008-08-12 20:41:04Z pcoustillas $ ?>
<?php   
/*Copyright (C) 2003-2004 Guy Hendrickx
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Guy Hendrickx
Modification : Pierre Coustillas */

require_once("include/verif.php");
require_once("include/config/common.php");
require_once("include/language/$lang.php");
require_once("include/utils.php");
require_once("include/headers.php");?>
<script type="text/javascript" src="javascripts/confdel.js"></script>

<script type="text/javascript" src="javascripts/tri_formulaire.js"></script>

<script language="javascript" src="javascripts/verifier_form.js" type="text/javascript"></script>
<script type="text/javascript">
function verif_form()
{
	if (verifier('client','black','nom','vide#carac_spec','login','carac_spec','pass','carac_spec','mail','mail'))
	{
		document.client.submit();
	} else {
		alert("<?php aff_lang('Une des valeurs saisies n\'est pas correcte. \nMerci de corriger avant de poursuivre. ') ?>")	
	}

}
</script>


<?php

?>

<table class="page" align="center">
	<tr>
		<td class="page" align="center">
			<?php
			require_once("include/head.php");
			?>
		</td>
	</tr>
	<tr> 
		<td class="page" align="center">
			<?php
			if ($user_cli == "n") {
			echo"<h1>$lang_client_droit</h1>";
			exit;
			}

			if (isset($_GET['message']))
			{
				echo "<h1>" . $_GET['message'] . "</h1>";
			}

			$sql = " SELECT * FROM ${tblpref}client WHERE actif != 'non' ";
			$tri_ordre=isset($_GET['tri_ordre'])?$_GET['tri_ordre']:"ASC"; //ordre de tri
			$tri_champ=isset($_GET['tri_champ'])?$_GET['tri_champ']:"nom"; // champ de tri

         $sql .= " ORDER BY $tri_champ $tri_ordre";

			$req = mysql_query($sql) or die("Erreur SQL !<br/>$sql<br/>" . mysql_error());
			?>
			<center>
			<form name="frm_liste_cli" method="get" action="client_lister.php">
				<input type="hidden" name="tri_champ" value="<?php echo $tri_champ ?>" />
				<input type="hidden" name="tri_ordre" value="<?php echo $tri_ordre ?>" />
			</form>
			<table class="boiteaction">

				<caption><?php echo $lang_clients_existants; ?></caption>
				<tr>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','civ')"><?php echo $lang_civ; ?> </a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','nom')"><?php echo $lang_nom; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','nom2')"><?php echo $lang_complement; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','rue')"><?php echo $lang_rue; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','cp')"><?php echo $lang_code_postal; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','ville')"><?php echo $lang_ville; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','num_tva')"><?php echo $lang_numero_tva; ?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','tel')"><?php echo $lang_tele;?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','fax')"><?php echo $lang_fax;?></a></th>
					<th><a href="javascript:ecrit_ordre_et_post('frm_liste_cli','mail')"><?php echo $lang_email; ?></a></th>
					<th colspan="2"><?php echo $lang_action; ?></th>
				</tr>
				<?php
				$nombre =1;
				while($data = mysql_fetch_array($req))
					{
						$nom = $data['nom'];
						$nom_html= addslashes($nom);
						$nom2 = $data['nom2'];
						$rue = $data['rue'];
						$ville = $data['ville'];
						$cp = $data['cp'];
						$tva = $data['num_tva'];
						$mail =$data['mail'];
						$num = $data['num_client'];
						$civ = $data['civ'];
						$tel = $data['tel'];
						$fax = $data['fax'];
						$nombre = $nombre +1;
						if($nombre & 1){
						$line="0";
						}else{
						$line="1";
					}
					?>
				<tr class="texte<?php echo "$line" ?>" onmouseover="this.className='highlight'" onmouseout="this.className='texte<?php   echo"$line" ?>'">
					<td class="highlight"><?php echo $civ; ?></td>
					<td class="highlight"><?php echo $nom; ?></td>
					<td class="highlight"><?php echo $nom2; ?></td>
					<td class="highlight"><?php echo $rue; ?></td>
					<td class="highlight"><?php echo $cp; ?></td>
					<td class="highlight"><?php echo $ville; ?></td>
					<td class="highlight"><?php echo $tva; ?></td>
					<td class="highlight"><?php echo $tel; ?></td>
					<td class="highlight"><?php echo $fax; ?></td>
					<td class="highlight">
						<a href="mailto:<?php echo $mail; ?>" ><?php echo "$mail"; ?></a>
					</td>
					<td class="highlight">
						<a href='client_edit.php?num=<?php echo "$num" ?>'><img border='0' src='image/edit.png' alt='<?php echo $lang_editer; ?>' /></a>
					</td>
					<td class="highlight">
						<a href='client_delete.php?num=<?php echo "$num"; ?>' onclick="return confirmDelete('<?php echo"$lang_cli_effa $nom_html ?"; ?>')"><img border='0' src='image/delete.png' alt='<?php echo $lang_supprimer; ?>' /></a>
					</td>
				</tr>
				<?php
				}

			?>

			</table>
			</center>
		</td>
	</tr>

	<tr><td><br/><hr/><br/></td></tr>
	

	<?php // Création des client ?>

	<tr>
		<td>

			<center>
			<form action="client_creer.php" method="post" name="client" >
			<table>
				<caption><?php echo $lang_client_ajouter; ?> &nbsp;  &nbsp;  &nbsp; <?php bouton_aide("client") ?></caption>
				<tr>
					<td class="texte0">Civilité</td>
					<td class="texte0"><input name="civ" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1"><div id="nom"><?php echo $lang_nom; ?> <strong>*</strong></div></td>
					<td class="texte1"><input name="nom" type="text" /></td>
				</tr>
				<tr>
					<td class="texte0"><?php echo $lang_complement; ?></td>
					<td class="texte0"><input name="nom_sup" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1"><?php echo $lang_rue; ?></td>
					<td class="texte1"><input name="rue" type="text" /></td>
				</tr>
				<tr>
					<td class="texte0"><?php echo $lang_code_postal; ?></td>
					<td class="texte0"><input name="code_post" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1"><?php echo $lang_ville; ?></td>
					<td class="texte1"><input name="ville" type="text" /></td>
				</tr>
				<tr>
					<td class="texte0"><?php echo $lang_numero_tva; ?></td>
					<td class="texte0"><input name="num_tva" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1">Téléphone </td>
					<td class="texte1"><input name="tel" type="text" /></td>
				</tr>
				<tr>
					<td class="texte0">Fax</td>
					<td class="texte0"><input name="fax" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1" id="mail"><?php echo $lang_email; ?></td>
					<td class="texte1"><input name="mail" type="text" /></td>
				</tr>
				<tr>
					<td class="submit" colspan="2" >
						<u><?php aff_lang("Connexion client") ?></u>
						<br/>
						<?php aff_lang("Ces données sont optionnelles et permettront à ce client de consulter ses devis, commandes et factures en ligne. ") ?>
						<br/>
						<?php aff_lang("Si vous avez renseigné le champ «&nbsp;E-mail&nbsp;», un E-mail spécifiant ses données d'identification lui sera envoyé. ") ?> 
					</td>
				</tr>
				<tr>
					<td class="texte0" id="login"><?php echo $lang_login; ?></td>
					<td class="texte0"><input name="login" type="text" /></td>
				</tr>
				<tr>
					<td class="texte1" id="pass"><?php echo $lang_mot_de_passe; ?></td>
					<td class="texte1"><input name="pass" type="text" /></td>
				</tr>
				<tr>
					<td class="submit" colspan="2">
						<input type="button" value="<?php aff_lang("  Créer ce client  ") ?>" onclick="verif_form()" />
					</td>
				</tr>
			</table>
			</form>
			</center>

		</td>
	</tr>



	<tr>
		<td>
			<?php
			require_once("include/bas.php");
			?>
		</td>
	</tr>

</table>
</body>
</html>
